package com.example.Hander;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class DateHander implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("createTime", new Date(),metaObject);
        setFieldValByName("updateTime", new Date(),metaObject);
//        setFieldValByName("createId", BaseContext.getCurrentId(),metaObject);
//        setFieldValByName("updateId",BaseContext.getCurrentId(),metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("updateTime",new Date(),metaObject);
//        setFieldValByName("updateId",BaseContext.getCurrentId(),metaObject);
    }
}
